<%--  This file is part of LitSearch.

    LitSearch is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    LitSearch is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with LitSearch; if not, write to the Free Software
    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA --%>

<jsp:useBean scope="page" id="exportObj" class="de.fhbrs.litsearch.ExportBean"  />
<jsp:useBean scope="session" id="mySearch" class="de.fhbrs.litsearch.SearchBean"  />
<jsp:useBean scope="session" id="myMedium" class="de.fhbrs.litsearch.MediumBean" />
<jsp:useBean scope="session" id="languageObj" class="de.fhbrs.litsearch.LanguageBean"  />
<%	exportObj.setLanguage(languageObj);
	if (request.getParameter("do").equals("csv")){
		response.reset();
		response.setHeader("Content-type","application/csv");
		response.setHeader("Content-disposition","inline; filename=csv-export.csv");
		if (request.getParameter("what").equals("wallet")) {
			out.print(exportObj.exportCSVWallet(mySearch));
		}
		else if (request.getParameter("what").equals("search")) {
			out.print(exportObj.exportCSVSearch(mySearch));
		}
		else if (request.getParameter("what").equals("details")) {
			out.print(exportObj.exportCSVDetails(myMedium));
		}
	}
	if (request.getParameter("do").equals("print")){
		if (request.getParameter("what").equals("wallet")) {
			out.print(exportObj.exportPrintWallet(mySearch));
		}
		else if (request.getParameter("what").equals("search")) {
			out.print(exportObj.exportPrintSearch(mySearch));
		}
		else if (request.getParameter("what").equals("details")) {
			out.print(exportObj.exportPrintDetails(myMedium));
		}
		else if (request.getParameter("what").equals("admin")) {
			out.print(exportObj.exportPrintAdmin(request.getParameter("mediaType"), request.getParameter("sortBy")));
		}
	}	
	if (request.getParameter("do").equals("bibtex")) {
		response.reset();
		response.setHeader("Content-type","application/bib");
		response.setHeader("Content-disposition","inline; filename=bibtex-export.bib");
		if (request.getParameter("what").equals("wallet")) {
			out.print(exportObj.exportBibtexWallet(mySearch));
		}
		else if (request.getParameter("what").equals("search")) {
			out.print(exportObj.exportBibtexSearch(mySearch));
		}
		else if (request.getParameter("what").equals("details")) {
			out.print(exportObj.exportBibtexDetails(myMedium));
		}
	}
%>